//
//  ListNovelCollectionViewCell.m
//  Read
//
//  Created by lanou on 15/12/17.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "ListNovelCollectionViewCell.h"
#import "UIImageView+AFNetworking.h"
#import "Novel.h"

@implementation ListNovelCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        CGFloat width = self.frame.size.width;
        CGFloat height = self.frame.size.height;
        
        _backView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, width, height))];
        _backView.backgroundColor = [UIColor whiteColor];
        [self addSubview:_backView];
        
        _pictureView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, width - 20, height - 60)];
        [self.backView addSubview:_pictureView];
        
        _bookNameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(0, self.pictureView.frame.size.height + 10, width, 30))];
        _bookNameLabel.font = [UIFont systemFontOfSize:14];
        _bookNameLabel.textAlignment = NSTextAlignmentCenter;
        _bookNameLabel.backgroundColor = kMyColor;
        [self.backView addSubview:_bookNameLabel];
        
        _authorLabel = [[UILabel alloc] initWithFrame:(CGRectMake(0, self.bookNameLabel.frame.origin.y + 30, width, 30))];
        _authorLabel.font = [UIFont systemFontOfSize:14];
        _authorLabel.textAlignment = NSTextAlignmentCenter;
        [self.backView addSubview:_authorLabel];
        
    }
    return self;
}


- (void)setNovel:(Novel *)novel {
    
    if (_novel != novel) {
        [_pictureView setImageWithURL:[NSURL URLWithString:novel.coverImgUrl] placeholderImage:[UIImage imageNamed:@"344334_bw.jpg"]];
        _bookNameLabel.text = novel.book_name;
        _authorLabel.text = novel.author;
    }
}



@end
